<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../util/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>导入数据</title>
</head>
<body>
<div id="importMdDataData" style="background-color:#FFFFFF;width:630px;margin:0 auto;">
        <div class="form-Container">
            <form action="${pageContext.request.contextPath}/mdData/checkReaptDataFile.do"  id="importProducs" class="easyUIForm" method="post" enctype="multipart/form-data">
                <table>
                    <tr>
                        <td width="150"><label for="checkMsg">新产品ID文件:</label></td>
                        <td colspan="3" style="line-height:20px;">
                            <input type="file" id="impFile" name="impFile" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align: center;">
                            <input type="button" value="导入进行检查" name="submitData"  />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align: center;line-height: 22px">
                            *<a href="<%=basePath %>/excel/reaptData.txt">***点我下载模板****</a><br/>
                            *录入数据时请按照模板中的格式来整理<br/>
                            *文件必需是txt文件，否则导入会失败<br/>
                        </td>
                    </tr>
                </table>
                <div id="confirmMsg"></div>
            </form>
        </div>			        
        <script type="text/javascript">
    	var baseId = "#importMdDataData ";
        $(document).ready(function () {
        	//提交表单数据
        	submitFormData();
        });
        
        //提交表单数据
        function submitFormData(){
        	//保存基本信息
        	$(baseId+" input[name='submitData']").click(function(){
          			    //弹出提示
          	            $.messager.progress({
          	            	msg:"正在为你导入数据,请稍后..."
          	            }); 
		        		$(baseId+" #importProducs").form('submit',{
		        			//当提交时
		        			onSubmit:function(param){
		        				//当提交时先验证一下表单
		        				if(!$(this).form("validate")){
		        					return false;
		        				}
		        			},
		        			success:function(data){
		        				var response = eval('(' + data + ')');
		        				//关闭提示
		                        $.messager.progress('close');
		        				if(response.code=='00'){
		          				  $.messager.show({
		          					 title:'系统提示',
		          					 msg:'数据检查成功,没有重复项,可放心使用',
		          					 timeout:2000,
		          					 showType:'slide'
		          				  });
		          				  var tmid = window.setTimeout("$(\"#editDataFormArea\").window(\"close\")", "1000");
		          				  tableObject.datagrid("reload");
		          			    }else{
		          				   $.messager.alert('操作提示',"检查失败，以下数据存在重复:<br/>"+response.msg,'error');
		          			    }
		        			}
		        		});
        	})
        }
        </script>
      </div>
</body>
</html>